﻿using Ewell.BizComponent.Reg.UI.VM;
using MahApps.Metro.Controls;
using System.Collections.Generic;
using System.Windows;

namespace Ewell.BizComponent.Reg.UI
{
    /// <summary>
    /// OutRegFrm.xaml 的交互逻辑
    /// </summary>
    public partial class OutRegFrm : MetroWindow
    {
        public OutRegVm vm { get; set; }
        /// <summary>
        /// 挂号结果
        /// </summary>
        //public ChargeResultVm outRegResult { get; set; }
        public OutRegFrm()
        {
            InitializeComponent();
            this.Topmost = true;
        }
        public OutRegFrm(OutRegVm vm): this()
        {
            this.vm = vm;
            this.vm.localWindow = this;
            //this.vm.NoticePreChargeResult += OnPreCharged;
            DataContext = this.vm;
        }
        ///// <summary>
        ///// 预算响应事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="result"></param>
        //private void OnPreCharged(object sender, PreChargeResultVm result)
        //{
        //    if (!result.success) return;
        //    ChargingInfoVm chargingInfo = new ChargingInfoVm()
        //    {
        //        settlementId= result.settlementId,
        //        amount= result.amount,
        //        discountAmount= result.discountAmount,
        //        encounterId=result.encounterId,
        //        settlementTypeCode=result.settlementTypeCode
        //    };
        //    List<Charge.UI.VM.PayWayVm> payWayVms = new List<Charge.UI.VM.PayWayVm>();
        //    foreach (var item in this.vm.payWayList)
        //    {
        //        payWayVms.Add(item.CopyProperties<Charge.UI.VM.PayWayVm>());
        //    }
        //    CashierVm cashierVm = new CashierVm(chargingInfo, payWayVms);
        //    cashierVm.patientVm = this.vm.patient.CopyProperties<Charge.UI.VM.PatientVm>();
        //    cashierVm.NoticeChargeResult += OnCharged;
        //    cashierVm.NoticeChargeCancel += OnChargeCancel;
        //    CashierFrm cashierFrm = new CashierFrm(cashierVm);
        //    //cashierVm.localWindow = cashierFrm;
        //    //cashierFrm.Owner = this;
        //    //cashierFrm.ShowDialog();
        //    //contentFrame.Content = cashierFrm;
        //    //contentFrame.Visibility = Visibility.Visible;
        //}
        ///// <summary>
        ///// 结算响应事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="result"></param>
        //private void OnCharged(object sender, CashierContext result)
        //{
        //    MessageBox.Show("挂号成功!");
        //    this.DialogResult = true;
        //    this.Close();
        //}
        ///// <summary>
        ///// 结算取消事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="result"></param>
        //private void OnChargeCancel(object sender, CashierContext result)
        //{
        //    //contentFrame.Visibility = Visibility.Collapsed;
        //    //OutRegisterServer outRegisterServer = new OutRegisterServer();
        //    //outRegisterServer.PreRegistCancel(new List<string>() { result.encounterId.ToString() });
        //}

        private void hasSchedBtn_Checked(object sender, RoutedEventArgs e)
        {
            //if (this.vm.hasSched)
            //{
            //    quantityCol.Visibility = Visibility.Visible;
            //    quantityUsedCol.Visibility = Visibility.Visible;
            //    quantityRemainCol.Visibility = Visibility.Visible;
            //    noonTypeNameCol.Visibility = Visibility.Visible;
            //}
            //else
            //{
            //    quantityCol.Visibility = Visibility.Collapsed;
            //    quantityUsedCol.Visibility = Visibility.Collapsed;
            //    quantityRemainCol.Visibility = Visibility.Collapsed;
            //    noonTypeNameCol.Visibility = Visibility.Collapsed;
            //}
        }

        private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //this.vm.register.Execute(this.vm.selectedSchedule);
        }
    }
}
